package com.situ.cloud.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.situ.cloud.common.util.StringUtil;
import com.situ.cloud.user.entity.User;
import com.situ.cloud.user.mapper.UserMapper;
import com.situ.cloud.user.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author kkkkkk
 * @since 2023-10-24
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Override
    public List<User> selectList(String username, String status, Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
        if (StringUtil.isNotBlank(username)) {
            wrapper.like(User::getUsername, username);
        }
        if (StringUtil.isNotBlank(status)) {
            wrapper.eq(User::getStatus, status);
        }
        return baseMapper.selectList(wrapper);
    }
}
